<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:ui="http://java.sun.com/jsf/facelets" 
	  xmlns:p="http://primefaces.prime.com.tr/ui" >
	  
	<f:view contentType="text/html"/>
	<f:metadata>
		<f:viewParam name="id" value="#{associadoBean.associado}" />
	</f:metadata>
	<h:body>
		<ui:composition template="layout.xhtml">
		<ui:define name="conteudo">
		<h2>Cadastro de Associados</h2>
		<h:form id="dados">
		<h:messages id="mensagens" style="color: red" showDetail="false"/>
		<fieldset>
			<legend>Dados do Associado</legend>
			<br></br>
			<h:panelGrid columns="2">
				<h:outputLabel value="Id:" for="id" 
						     rendered="#{associadoBean.associado.id != null}"
						     />
				<h:inputText id="id" 
							 value="#{associadoBean.associado.id}"
							 rendered="#{associadoBean.associado.id != null}"
							 readonly="true"/>

				<h:outputText value="Tipo (*):"/>
					<h:selectOneMenu value="#{associadoBean.associado.tipo}">  
			            <f:selectItem itemLabel="Fundador" itemValue="Fundador" />  
			            <f:selectItem itemLabel="Efetivo" itemValue="Efetivo" />  
			            <f:selectItem itemLabel="Honorário" itemValue="Honorário" />  
			            <f:selectItem itemLabel="Contribuinte" itemValue="Contribuinte" />
		        	</h:selectOneMenu> 

				<h:outputLabel value="Nome (*):" for="nome"/>
				<h:inputText id="nome" value="#{associadoBean.associado.nome}"  required="true" requiredMessage="Informe o Nome do Associado"/>
				
				<h:outputLabel value="CPF:" for="cpf"/>
				<p:inputMask id="cpf" mask="999.999.999-99" 
					value="#{associadoBean.associado.cpf}"/>
				
				<h:outputLabel value="Data de Nascimento:" for="dataNascimento" />
				<p:calendar pattern="dd/MM/yyyy" id="dataNascimento"
					value="#{associadoBean.associado.dataNascimento.time}"/>				
				
				<h:outputLabel value="E-mail:" for="email"/>
				<h:inputText id="email" value="#{associadoBean.associado.email}"/>

				<h:outputLabel value="Telefone:" for="telefone"/>
				<p:inputMask id="telefone" mask="(99)9999-9999" value="#{associadoBean.associado.telefone}"/>

				<h:outputLabel value="Endereço:" for="endereco"/>
				<h:inputText id="endereco" value="#{associadoBean.associado.endereco}"/>

				<h:outputLabel value="Data de Admissão:" for="dataAdmissao"/>
				<p:calendar pattern="dd/MM/yyyy" id="dataAdmissao" value="#{associadoBean.associado.dataAdmissao.time}"/> 
				
			</h:panelGrid>
			<br></br>
				&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
				<h:commandLink actionListener ="#{associadoBean.salvar}"  title="Salvar">
					<img src="resources/imagens/ok.jpg" alt="Salvar"/> </h:commandLink>
					&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
				<a href="#{facesContext.externalContext.request.contextPath}/associadoList.xhtml" title="Cancelar">
					<img src="resources/imagens/Xcancelar.jpg" alt="Cancelar"/> </a>
		</fieldset>
		</h:form>
		</ui:define>
		</ui:composition>
	</h:body>
</html>